package com.fhz.kotlinstest

import android.util.Log
import com.google.gson.Gson
import dagger.Binds
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import javax.inject.Inject
import javax.inject.Singleton


@Module
@InstallIn(SingletonComponent::class)
class HttpMoudle {


    @Provides
    @Singleton
    fun provideRetrofit(): ApiService {
        Log.i("fff", "provideRetrofit: ")
        return Retrofit.Builder()
            .baseUrl("http://10.161.9.80:9999/banner/")
            .client(OkHttpClient.Builder()
                .addInterceptor(HttpLoggingInterceptor()
                .setLevel(HttpLoggingInterceptor.Level.BODY))
                .build())
            .addConverterFactory(GsonConverterFactory.create())
            .build().create(ApiService::class.java)
    }

//    @FengRetrofit
//    @Provides
//    fun provideRetrofit1(): Retrofit {
//        return Retrofit.Builder()
//            .baseUrl("https://dev.abc/")
//            .client(OkHttpClient.Builder()
//                .addInterceptor(HttpLoggingInterceptor()
//                    .setLevel(HttpLoggingInterceptor.Level.BODY))
//                .build())
//            .addConverterFactory(GsonConverterFactory.create())
//            .build()
//    }

}